package com.rm.wechatapp.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.rm.wechatapp.entity.OnCategory;
import com.rm.wechatapp.service.IOnCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @Author: xy
 * @Date: 2025/3/18 9:38
 */
@Slf4j
@RestController
@RequestMapping("/api/categories")
public class WeCategoryController {

    @Autowired
    private IOnCategoryService shTkCategoriesService;

    /**
     * 根据父分类ID查找其下的分类信息
     * @param fatherId 父分类ID
     * @return
     * @throws JsonProcessingException
     */
    @GetMapping("/{father_id}")
    @ResponseBody
    public List<OnCategory> getByFatherId(@PathVariable("father_id") String fatherId) throws JsonProcessingException {
        return shTkCategoriesService.selectByFatherId(fatherId);
    }

}
